package com.example.controller.drug;


import com.example.common.Result;
import com.example.entity.drugDTO.DrugMatchingRequest;
import com.example.service.drug.DrugMatchingService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/drug")
public class DrugMatchingController {
    private final DrugMatchingService drugMatchingService;

    public DrugMatchingController(DrugMatchingService drugMatchingService) {
        this.drugMatchingService = drugMatchingService;
    }

    /**
     * 药品推荐接口
     * @param request 药品推荐请求
     * @return 统一结果封装
     */
   /*
  postman示例
   {
    "gender": "男",
    "age": 30,
    "symptom": "发烧",
    "allergy": "无",
    "temperature": 38.5
}
    */
    @PostMapping("/recommend")
    public Result recommendDrug(@RequestBody DrugMatchingRequest request) {
        try {
            String medicine = drugMatchingService.recommendMedicine(request);
            return Result.success(medicine);
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }


}